package com.htc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.htc.dao.BannerMapper;
import com.htc.model.Banner;
import com.htc.model.PageResult;
import com.htc.model.request.BannerRequest;

@Service
public class BannerService {
    
	@Autowired
	private BannerMapper bannerMapper;
	
	public PageResult<Banner> queryList(BannerRequest request) {
		Page page = PageHelper.startPage(request.getPage(), request.getLimit());
		List<Banner> list =  bannerMapper.queryList(request.convertWhereStr());
		return new PageResult<Banner>(list, page.getTotal(), page.getPageSize(), page.getPageNum());
	}
	
	public void add(Banner room) {
		bannerMapper.insert(room);
	}
	
	public void update(Banner room) {
		bannerMapper.update(room);
	}
	
	public void del(int id) {
		bannerMapper.del(id);
	}

	public List<Banner> findAll() {
		return bannerMapper.queryList("");
	}
	
}
